#! /bin/sh

. ./prelude

bspc wm -a "TEST-SWAP-A" 1024x512+0+0
bspc wm -a "TEST-SWAP-B" 1024x512+0+512

bspc monitor -f "TEST-SWAP-A"
window add 3

bspc monitor -f "TEST-SWAP-B"
window add 2

nodes_a=$(bspc query -N -m "TEST-SWAP-A")
nodes_b=$(bspc query -N -m "TEST-SWAP-B")

bspc desktop "TEST-SWAP-A:^1" -s "TEST-SWAP-B:^1"

[ "$(bspc query -N -m 'TEST-SWAP-A')" = "$nodes_b" ] || fail "Wrong nodes in first monitor"
[ "$(bspc query -N -m 'TEST-SWAP-B')" = "$nodes_a" ] || fail "Wrong nodes in second monitor"

window remove 3
bspc monitor -f "TEST-SWAP-A"
window remove 2

bspc monitor "TEST-SWAP-A" -r
bspc monitor "TEST-SWAP-B" -r
